package com.rqf.mr.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.rqf.mr.service.ILoginService;

@Service("LoginService")
public class LoginService implements ILoginService {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	/**
	 * 
	 * @param name
	 * @param password
	 * @return
	 * @author HelloWorld_luo
	 * @date 2016年4月18日
	 */
	@Override
	public Boolean login(String name, String password) {
		if (StringUtils.isEmpty(name) || StringUtils.isEmpty(password)) {
			return false;
		}
		// 验证用户
		String sql = "Select  * from view_ehisuser where LOGINNAME='"
				+ name + "'and EMPPASSWORD='" + password + "'";
		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
		if (list.size() > 0) {
			return true;
		}else {
			return false;
		}
	}
	
	@Override
	public List<Map<String, Object>> searchDepartmentInfo() {
		String sql = "select * from view_ehisorganization";
		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
		return list;
	}

	@Override
	public List<Map<String, Object>> getNurseInfo(String nurseLoginId) {
		if ( StringUtils.isEmpty(nurseLoginId) ) {
			return null;
		}
		String sql = "Select  * from view_ehisuser where LOGINNAME='"
				+ nurseLoginId + "'";
		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
		return list;
	}

}
